package com.hanagent;

import com.hanagent.controller.AdminController;
import com.hanagent.controller.AgentController;
import com.hanagent.controller.AgentOrdersController;
import com.hanagent.controller.DefaultController;
import com.hanagent.controller.GoodController;
import com.hanagent.controller.MoneyController;
import com.hanagent.controller.OrdersController;
import com.hanagent.controller.PostalsController;
import com.hanagent.controller.UploadController;
import com.hanagent.interceptor.GlobalActionInterceptor;
import com.hanagent.model._MappingKit;
import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.ModelRecordElResolver;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;
 
public class HanAgentConfig extends JFinalConfig {

	public static String uploadPathString = "hanagentUpload/uploadImg";
	
	public void configConstant(Constants me) {
		me.setDevMode(true);
		me.setBaseUploadPath("../"+uploadPathString);
	}

	public void configRoute(Routes me) { 
		me.add("/", DefaultController.class);
		me.add("/hanagent/private/good", GoodController.class);
		me.add("/hanagent/private/admin", AdminController.class);
		me.add("/hanagent/private/upload", UploadController.class);
		me.add("/hanagent/private/order", OrdersController.class);
		me.add("/hanagent/private/agent", AgentController.class);
		me.add("/hanagent/private/agentOrder", AgentOrdersController.class);
		me.add("/hanagent/private/money", MoneyController.class);
		me.add("/hanagent/private/postal", PostalsController.class);
	}

	public void configEngine(Engine me) {
		
	} 

	public void configPlugin(Plugins me) {
		//todo 测试环境  记得改啊  要不然搞死人的
		DruidPlugin dp = new DruidPlugin("jdbc:mysql://120.79.134.87:3306/hanagent?useUnicode=true&characterEncoding=utf-8&useSSL=false&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai", "myuser", "mypassword");
		//todo 正式环境，记得改啊  要不然搞死人的
//		DruidPlugin dp = new DruidPlugin("jdbc:mysql://rm-wz9sd1hx408pbkj6o.mysql.rds.aliyuncs.com:3306/hanagent?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai", 
//				"hanguyuan", "Ap&0806321");
		
		me.add(dp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
		arp.setShowSql(true);
		_MappingKit.mapping(arp);
		me.add(arp); 
	}

	public void configInterceptor(Interceptors me) {
		// 添加控制层全局拦截器
		me.addGlobalActionInterceptor(new GlobalActionInterceptor());
	}

	public void configHandler(Handlers me) {
		
	}
	
	@Override
	public void afterJFinalStart() {
		super.afterJFinalStart();
		ModelRecordElResolver.setResolveBeanAsModel(true);
	}
	
}





